/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cse308.entities;

import cse308.GeneralEntity;
import cse308.helper_classes.GeneralTest;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Aaron
 */
@Entity
@Table(catalog = "nchorn", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Courseoutcomesurveyresults.findAll", query = "SELECT c FROM Courseoutcomesurveyresults c"),
    @NamedQuery(name = "Courseoutcomesurveyresults.findByAverageRatingAttainment", query = "SELECT c FROM Courseoutcomesurveyresults c WHERE c.averageRatingAttainment = :averageRatingAttainment"),
    @NamedQuery(name = "Courseoutcomesurveyresults.findByUid", query = "SELECT c FROM Courseoutcomesurveyresults c WHERE c.uid = :uid")})
public class Courseoutcomesurveyresults implements Serializable, GeneralEntity {

    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @NotNull
    @Column(nullable = false)
    private int averageRatingAttainment;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(nullable = false)
    private Integer uid;
    @JoinColumn(name = "courseoutcomeIdentifier", referencedColumnName = "identifier")
    @ManyToOne
    private Courseoutcome courseoutcomeIdentifier;
    @JoinColumns({
        @JoinColumn(name = "course", referencedColumnName = "course"),
        @JoinColumn(name = "section", referencedColumnName = "section"),
        @JoinColumn(name = "semester", referencedColumnName = "semester")})
    @ManyToOne
    private Courseoffering courseoffering;
    

    public Courseoutcomesurveyresults() {
    }

    public Courseoutcomesurveyresults(Integer uid) {
        this.uid = uid;
    }

    public Courseoutcomesurveyresults(Integer uid, int averageRatingAttainment) {
        this.uid = uid;
        this.averageRatingAttainment = averageRatingAttainment;
    }

    public int getAverageRatingAttainment() {
        return averageRatingAttainment;
    }

    public void setAverageRatingAttainment(int averageRatingAttainment) {
        this.averageRatingAttainment = averageRatingAttainment;
    }

    public Integer getUid() {
        return uid;
    }

    public void setUid(Integer uid) {
        this.uid = uid;
    }

    public Courseoutcome getCourseoutcomeIdentifier() {
        return courseoutcomeIdentifier;
    }

    public void setCourseoutcomeIdentifier(Courseoutcome courseoutcomeIdentifier) {
        this.courseoutcomeIdentifier = courseoutcomeIdentifier;
    }

    public Courseoffering getCourseoffering() {
        return courseoffering;
    }

    public void setCourseoffering(Courseoffering courseoffering) {
        this.courseoffering = courseoffering;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (uid != null ? uid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Courseoutcomesurveyresults)) {
            return false;
        }
        Courseoutcomesurveyresults other = (Courseoutcomesurveyresults) object;
        if ((this.uid == null && other.uid != null) || (this.uid != null && !this.uid.equals(other.uid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cse308.entities.Courseoutcomesurveyresults[ uid=" + uid + " ]";
    }
     @Override
    public List<List<GeneralEntity>> getAssociatedClasses() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public List<GeneralEntity> getAssociatedClass(String associated) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void setWithClass(GeneralTest gt) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void testAddClass(GeneralEntity ge) {
        if (ge instanceof Courseoffering) {
            this.courseoffering = (Courseoffering) ge;
        }
    }

    @Override
    public void removeClass(GeneralEntity ge) {
        if (ge instanceof Courseoffering) {
            this.courseoffering = null;
        }
    }

    @Override
    public GeneralEntity findCorrespondingEntity() {
        return this;
    }

    @Override
    public String getIdentifier2() {
        return String.valueOf(this.uid);
    }

    @Override
    public boolean equalsEntity(GeneralEntity entity) {
        return this.equals(entity);
    }  

    @Override
    public Object getPK() {
        return this.uid;
    }
}